package model;

import java.awt.Color;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

/**
 * @author Morten
 */
public class Bid {
    
    private final String time;
    private final int amount;
    private final Auction auction;
    private final User user;
    DateFormat dateFormat = new SimpleDateFormat("dd/mm/yy HH:mm:ss");
    Date date = new Date();

    public Bid(Auction auction, User user, int amount) {
	this.auction=auction;
	this.user=user;
	this.amount = amount;
	this.time = dateFormat.format(date);
    }
    public ArrayList calcBid(int bid){
	return calcBid(bid, false);
    }
    
    public ArrayList calcBid(int bid,boolean bool){
	ArrayList res=new ArrayList();
	double newBid=bid;
	double oldBid=amount;
	double bidDifference = (newBid-oldBid);
	if(bidDifference>(oldBid/10)){
	    res.add(true);
	    if(bool){
		res.add("Buddet blev godkendt");
	    }else{
		res.add("Tilladt bud");
	    }
	    res.add(new Color(150,210,30));
	}else{
	    res.add(false);
	    res.add("For lavt bud! Min. "+ getValidBid());
	    res.add(new Color(225,30,30));
	}
	return res;
    }
    public int getValidBid(){
	return (int)(amount*1.1+1);
    }
    public String getTime() {
	return time;
    }

    public int getAmount() {
	return amount;
    }

    public Auction getAuction() {
	return auction;
    }

    public User getUser() {
	return user;
    }
    
}
